package regex;

import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class myMatherDemo {
    private static final String REGEX ="\\bdog\\b";
    private static final  String INPUT = "dog dog dog doggie dogg";

    @Test
    public void matherDemo(){
        //检查字符串里面有多少个dog
        Pattern p = Pattern.compile(REGEX);
        Matcher m = p.matcher(INPUT);
        int count =0;
        while(m.find()) {
            count++;
            System.out.println("Match number "+count);
            System.out.println("start():"+m.start());
            System.out.println("end():"+m.end());
        }
    }


}
